package cate.game.pvp.eliterace.data;

import cate.game.rank.po.Rank;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Data
@Document(collection = "elite-race-rank")
public class EliteRaceRank extends Rank {
    public static final String INDEX_NAME = "INDEX";

    @Id
    private String uid;

    private int winCount;
    private int looseCount;

    public static EliteRaceRank of(EliteRacePs ps) {
        EliteRaceRank rank = new EliteRaceRank();
        rank.setUid(ps.getUid());
        rank.value = ps.getOpponent().getPoints();
        rank.owner = ps.getOpponent().getSnapshot();
        rank.setWinCount(ps.getOpponent().getWinCount());
        rank.setLooseCount(ps.getOpponent().getLooseCount());
        rank.recordTime = System.currentTimeMillis();
        return rank;
    }
}
